<?php

/*
 * Action 6$
 *
 * +4 Cards
 * When you trash this, gain a Duchy or 3 Estates.
 */

class HuntingGrounds extends Card implements iAction, iKingdom, iDarkAges {

    public function __construct() {
        parent::__construct("Hunting Grounds", 6);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+4 Cards",
            "When you trash this, gain a Duchy or 3 Estates.");
    }

    public function trash(Game $game, $name) {
        $options = array(new Option(1, "Gain Duchy"), new Option(2, "Gain 3 Estates"));
        $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "Please choose", $name);
        $answer = $output[0];
        if ($answer == "Gain Duchy") {
             $s = $game->moveCardFromPileToPile("Duchy", BoardCards, DiscardPile, $name);
             ScreenDisplay::addScreenMessage($game, true, "gain " . nicePrint($s), " gains " . ScreenDisplay::$LMSG, $name);
        } else {
            $s1 = $game->moveCardFromPileToPile("Estate", BoardCards, DiscardPile, $name);
            $s2 = $game->moveCardFromPileToPile("Estate", BoardCards, DiscardPile, $name);
            $s3 = $game->moveCardFromPileToPile("Estate", BoardCards, DiscardPile, $name);

            $estates = array();
            if ($s1)
                $estates[] = $s1;
            if ($s2)
                $estates[] = $s2;
            if ($s3)
                $estates[] = $s3;

            ScreenDisplay::addScreenMessage($game, true, "gain " . nicePrint($estates), " gains" . ScreenDisplay::$LMSG, $name);
        }
        $game->setTempCard($this);
        $game->cardTrashFinished($name);
    }

    public function play(Game $game, $isRealCard) {
        $drawed_cards = $game->drawCards(4);
        ScreenDisplay::addScreenMessage($game, true, "draw  " . nicePrint($drawed_cards), "draws " . sizeof($drawed_cards) . " cards");
        $game->cardActionFinished();
        return true;
    }

}

?>